package com.start.security;

import com.start.common.details.BaseUserDetails;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
 @Schema(name="")
public class UserTokenEntity {
    private String userName;
    private String userType;
    private String userId;
    private String ipAddress;
    private String userDetailsClazz;

    public UserTokenEntity() {

    }

    /**
     * 用户信息
     *
     * @param userId   用户id
     * @param userName 用户名
     * @param userType 用户类型
     */
    public UserTokenEntity(String userId, String userName, String userType) {
        this.userId = userId;
        this.userName = userName;
        this.userType = userType;
    }

    /**
     * 用户信息
     *
     * @param userDetails
     */
    public UserTokenEntity(BaseUserDetails userDetails, String ipAddress) {
        this.userName = userDetails.getUsername();
        this.userType = userDetails.getStartUserType();
        this.userId = userDetails.getUserId();
        this.userDetailsClazz = userDetails.getClass().getName();
        this.ipAddress = ipAddress;
    }
}
